CMAKE_MINIMUM_REQUIRED(VERSION 2.4)

IF(COMMAND cmake_policy)
      cmake_policy(SET CMP0003 NEW)
ENDIF(COMMAND cmake_policy)

PROJECT("LWIP LEON3")
#if you don't want the full compiler output, remove the following line
SET(CMAKE_VERBOSE_MAKEFILE ON) 


SET(CMAKE_C_FLAGS "-finline-limit=7000")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Winline")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wundef")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mv8")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msoft-float")

SET(LWIP_SOURCE "${PROJECT_SOURCE_DIR}/LWIP/src")

INCLUDE_DIRECTORIES(SYSTEM
    ${LWIP_SOURCE}/include
    ${LWIP_SOURCE}/include/ipv4
    ${LWIP_SOURCE}/include/ipv6
)

# set the library path
# LINK_DIRECTORIES(SYSTEM
#     /opt/sparc-elf-3.4.4/sparc-elf/lib
# )

SET(COREFILES
    ${LWIP_SOURCE}/core/mem.c
    ${LWIP_SOURCE}/core/memp.c 
    ${LWIP_SOURCE}/core/netif.c
    ${LWIP_SOURCE}/core/pbuf.c 
    ${LWIP_SOURCE}/core/stats.c
    ${LWIP_SOURCE}/core/sys.c
    ${LWIP_SOURCE}/core/raw.c
    ${LWIP_SOURCE}/core/tcp.c
    ${LWIP_SOURCE}/core/tcp_in.c
    ${LWIP_SOURCE}/core/tcp_out.c
    ${LWIP_SOURCE}/core/udp.c)

SET(CORE4FILES
    ${LWIP_SOURCE}/core/ipv4/icmp.c
    ${LWIP_SOURCE}/core/ipv4/ip.c
    ${LWIP_SOURCE}/core/inet.c
    ${LWIP_SOURCE}/core/ipv4/ip_addr.c
    ${LWIP_SOURCE}/core/ipv4/ip_frag.c)

SET(NETIFFILES 
    ${LWIP_SOURCE}/netif/etharp.c
    ${LWIP_SOURCE}/netif/loopif.c
    ${LWIP_SOURCE}/netif/grethif.c
    ${LWIP_SOURCE}/netif/slipif.c)

SET(ARCHFILES ${LWIP_SOURCE}/arch/lwip_arch.c)


ADD_LIBRARY(lwip ${COREFILES} ${CORE4FILES} ${ARCHFILES} ${NETIFFILES} )
ADD_DEFINITIONS(-DIPv4 -DNO_SYS)
ADD_SUBDIRECTORY(tests)


